/*
 * XCMouse
 * http://code.google.com/p/bit-eclipse/wiki/XCMouse
 *
 * Copyright 2012, Denzel Morris
 * Licensed under the MIT License.
 * See License.txt
 */

#pragma once
#ifndef __CONTROLLER_THREAD_H_INC__
#define __CONTROLLER_THREAD_H_INC__

#include <boost/thread.hpp>
#include <boost/signal.hpp>
#include <boost/function.hpp>

#include "XCMouse.h"
#include "ControllerState.h"

/////////////////////////////////////////////////////////////////////
//
// Allows the creation of a thread that polls the X360 controller
// at a given interval (right now 30 Hz)
//
// Only thread should be in existence at once
//
/////////////////////////////////////////////////////////////////////
class ControllerThread {
private:
	boost::thread mThread;
	boost::signal1<void, const ControllerState&> mSignal;

	XINPUT_STATE mLastState;
	XINPUT_STATE mCurrentState;

public:

	ControllerThread(boost::function1<void, const ControllerState&> slot);

	void start();
	void stop();

	// The actual threaded method
	void _process();
};

#endif // __CONTROLLER_THREAD_H_INC__